package org.jeecg.config.email;

import cn.hutool.extra.mail.MailAccount;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Data
@Configuration
@ConfigurationProperties(prefix = "mail.account")
public class MailConfig {
    private String host;
    private int port;
    private boolean auth;
    private String from;
    private String pass;
    private boolean sslEnable;

    @Bean("clueMailAccount")
    public MailAccount mailAccount() {
        MailAccount wyAccount = new MailAccount();
        wyAccount.setHost(host);
        wyAccount.setPort(port);
        wyAccount.setAuth(auth);
        wyAccount.setFrom(from);
         wyAccount.setUser(from); // Uncomment if needed
        wyAccount.setPass(pass);
        wyAccount.setSslEnable(sslEnable);
        return wyAccount;
    }
}
